package com.decade.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.decade.constants.Constants;
import com.decade.domain.SimpleUser;
import com.decade.mapper.MenuMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import com.decade.domain.Menu;
import com.decade.service.MenuService;
@Service
public class MenuServiceImpl implements MenuService{
    @Autowired
    private MenuMapper menuMapper;

    @Override
    public List<Menu> selectMenuTree(boolean isAdmin, SimpleUser simpleUser) {
        QueryWrapper<Menu> wrapper = new QueryWrapper<>();
        wrapper.eq(Menu.COL_STATUS, Constants.STATUS_TRUE);
        wrapper.in(Menu.COL_MENU_TYPE,Constants.MENU_TYPE_M,Constants.MENU_TYPE_C);
        wrapper.orderByAsc(Menu.COL_PARENT_ID);
        if(isAdmin){
            return menuMapper.selectList(wrapper);
        }else{
            //根据用户id查询用户用户的菜单信息
            return menuMapper.selectList(wrapper);
        }
    }
}
